/**
*      author: Y_Yao
*      created: 2025-04-09 13:26:36
**/

#include<bits/stdc++.h>

#define int LL
using namespace std;
using LL = long long;
const LL LLINF = 9e18;
const int INF = 0x3f3f3f3f;
const int N = 2e5 + 10;
string a[N];
int h,w,k;
int ans = INF;

void solve()
{
    cin >> h >> w >> k;
    for(int i = 1;i <= h;i++)
    {
        string s;
        cin >> s;
        a[i] = " " + s;
    }
    int cnt1 = 0;
    int cnt2 = 0;
    for(int i = 1;i <= h;i++)
    {
        cnt1 = cnt2 = 0;
        int l = 1,r = 1;
        for(r = 1;r <= w;r++)
        {
            if(a[i][r] == '.') cnt1++;
            if(a[i][r] == 'x') cnt2++;
            if(r - l + 1 > k)
            {
                if(a[i][l] == '.') cnt1--;
                if(a[i][l] == 'x') cnt2--;
                l++;
            }
            if(r - l + 1 >= k && cnt2 == 0)
            {
                ans = min(ans,cnt1);
            }
        }
    }
    for(int i = 1;i <= w;i++)
    {
        cnt1 = 0,cnt2 = 0;
        int l = 1,r = 1;
        for(r = 1;r <= h;r++)
        {
            if(a[r][i] == '.') cnt1++;
            if(a[r][i] == 'x') cnt2++;
            if(r - l + 1 > k)
            {
                if(a[l][i] == '.') cnt1--;
                if(a[l][i] == 'x') cnt2--;
                l++;
            }
            if(r - l + 1 >= k && cnt2 == 0)
            {
                ans = min(ans,cnt1);
            }
        }
    }
    if(ans == INF)
    {
        cout << -1 << endl;
        return;
    }
    cout << ans << endl;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int t = 1;
    // cin >> t;
    while(t--)
    {
        solve();
    }
    return 0;
}